//
// Created by Administrator on 2021/7/31.
//

#include "Geometry/Vector3.h"

void Vector3::Norm()
{
    float len2 = x() * x() + y() * y() + z() * z();
    if(len2 > 0)
    {
        float len = sqrtf(len2);
        x() /= len;
        y() /= len;
        z() /= len;
    }
}

Vector3 Vector3::Normalize() const
{
    float x = this->x(), y = this->y(), z = this->z();
    float len2 = x * x + y * y + z * z;
    if(len2 > 0)
    {
        float len = sqrtf(len2);
        x /= len;
        y /= len;
        z /= len;
    }

    return {x, y, z};
}

inline void Vector3::GetData(float *data) const
{
    data[0] = x_;
    data[1] = y_;
    data[2] = z_;
}